#! /usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import os
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from mwin import CrossMatesWindow
from bundles import BundleDict, BundleEditor

class CrossMatesApp(QApplication):
    '''
    A window per project?
    '''
    DEFAULT_BUNDLE_DIR = 'macromate/Bundles'
    def __init__(self, arguments):
        QApplication.__init__(self, arguments)
        self.__bundles = None
        self.startup()
        """
        self.setStyleSheet('''
        
            QWidget {
                
            }
            QMenu::item::selected {
                background-color: #336EC8;
            }
            QTextEdit {
                font-family: Monospace;
                font-size: 12px;
                color: #fff;
            }
            
            QScrollBar::handle {
                background: red;
                /*min-width: 20px;*/
            }
            QStatusBar #labelPosition {
                font-family: Monospace;
            }
        ''')
        """
        self.win = CrossMatesWindow()
        
    def exec_(self):
        self.win.show()
        
        return QApplication.exec_()
    
    def bundles():
        doc = "BundleDict property"
        def fget(self):
            return self.__bundles
        return locals()
    bundles = property(**bundles())
        
    
    def startup(self):
        # Application startup
        self.__bundles = BundleDict(self, os.path.join(os.getcwd(), 
                                            self.DEFAULT_BUNDLE_DIR)
                                    )
        self.bundleEdtorWindow = BundleEditor(self.bundles)
        